#include <iostream>
using namespace std;
bool check_leap(int year)
{
    if (year % 4 == 0 && year % 100 != 0)
        return true;
    if (year % 400 == 0)
        return true;

    return false;
}
int main() {
    int year, month, day, sum = 0;
    int data1[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
    int data2[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
    cin >> year >> month >> day;
    bool flag = check_leap(year);
    if (flag)
    {
        for (int i = 0; i < month - 1; ++i)
            sum += data2[i];

        sum += day;
        printf("%d\n", sum);
        sum = 0;
    }
    else {

        for (int i = 0; i < month - 1; ++i)
            sum += data1[i];

        sum += day;
        printf("%d\n", sum);
        sum = 0;

    }
}